import React, { Component } from 'react'
import {Navigate} from 'react-router-dom'
import {Card}from 'antd-mobile'
import {reqUserList} from '../../api/index'
export default class Boss extends Component {
    state={userlist:[],id:'',name:""}
    componentDidMount(){
        reqUserList({type:'laoban'}).then((res)=>{
            console.log(res,!res.code)
            if(!res.code){
                this.setState({userlist:res.data})
            }
        })
    }
    render() {
        if(this.state.id){
            return(
                <Navigate to={`/main/chat/${this.state.id}/${this.state.name}`}></Navigate>
            )
        }
        return (
            <div >
                {
                    this.state.userlist.map((item)=>{
                        return (
                            <Card key={item._id}  style={{margin:'10px 15px'}}
                                title={<img src={require(`../../assets/images/${item.header}.png`).default}  alt=""></img>}
                                extra={<span>{item.username}</span>}
                                headerStyle={{fontSize:'17px',color:'#888'}}
                                onClick={()=>{this.setState({id:item._id,name:item.username})}}
                                >
                                <div> 职位：{item.post} </div>
                                <div> 公司：{item.company } </div>
                                <div> 月薪：{item.salary} </div>
                                <div> 描述:{item.info} </div> 
                            </Card>
                        )
                    })
                }
                
            </div>
        )  
    }
}
